import {Route,Switch,Redirect} from 'react-router-dom'
import {oneLevel} from './router/index'
import { Suspense } from 'react'
import "antd/dist/antd.css";

function App() {
  return (
    <div className="App">
      {/* Suspense 懒加载包裹 */}
      <Suspense fallback={<div>加载中。。。。</div>}>
        {/* Switch 匹配一次 */}
        <Switch>
          {/* exact 细致匹配 */}
          {
            oneLevel.map((item,index)=>{
              if(item.exact){
                return <Route key={index} path={`${item.path}${item.parem?item.parem:''}`} component={item.component} exact></Route>
              }else{
                return <Route key={index} path={`${item.path}${item.parem?item.parem:''}`} component={item.component}></Route>
              }
            })
            // <Route  path='路由' children={组件} component={组件->优先级小于children} render={()=>{组件->优先级小于component}}></Route>
          }
          {/* <Redirect to="/首页" from=''></Redirect> */}
          
          {/* Redirect 重定向 */}
          {/* <Redirect to={adminRouter[0].pathname} from='/admin' exact></Redirect> */}
          <Redirect to="/shouye" ></Redirect>
        </Switch>
      </Suspense>
    </div>
  );
}

export default App;
